﻿using System;
using System.Collections.Generic;
using System.Text;
using X.Entity;
using System.Reflection;

namespace X.DataFactory
{
    public interface IParams
    {
        SiteInfo GetSiteInfo();
        bool UpdataSiteInfo(SiteInfo siteInfo);
    }

    public interface IMsn
    {
        MsnInfo GetMsnInfo(int id);
        IList<MsnInfo> GetAvaList();
        IList<MsnInfo> GetAllList();
        bool Update(MsnInfo msnInfo);
        bool Create(MsnInfo msnInfo);
        bool Delete(int id);
    }

    public interface IAd
    {
        bool Create(AdInfo adInfo);
        bool Update(AdInfo adInfo);
        bool Delete(int id);
        IList<AdInfo> GetAllList();
        IList<AdInfo> GetList(int topCount);
        AdInfo GetAdInfo(int id);
    }

    public sealed partial class DataAccess
    {
        public static IParams CreateParams()
        {
            string typeName = path + ".Params";

            return (IParams)Assembly.Load(path).CreateInstance(typeName);
        }

        public static IMsn CreateMsn()
        {
            string typeName = path + ".Msn";

            return (IMsn)Assembly.Load(path).CreateInstance(typeName);
        }

        public static IAd CreateAd()
        {
            string typeName = path + ".Ad";

            return (IAd)Assembly.Load(path).CreateInstance(typeName);
        }
    }
}
